<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./my.js"></script>
    <script>
        //函数求和
        function getsum(num1, num2) {
            var sum = 0;
            for (var i = num1; i <= num2; i++) {
                sum += i;
            }
            console.log(sum);

        }
        getsum(1, 100);

        //外部调用函数
        cook('大肘子');
    </script>


    <!-- 函数返回值 -->
    <script>
        function getodd(num1, num2) {
            var mutiple = 1;
            for (var i = num1; i <= num2; i++) {
                if (i % 2 == 1) {
                    mutiple += i;
                }
            }
            return mutiple;

        }

        var result = getodd(1, 100);
        console.log(result);


        //函数第二种声明方式  函数表达式
        var fun = function(aru) {
            console.log('我是一个函数表达式');
            console.log(aru);
        }

        fun('周黑鸭');

        // 第三种立即执行函数
        (function(a, b) {
            console.log(a + b);
        })(1, 2);

        (function(a, b) {
            console.log(a + b);
        }(1, 2))
    </script>

</head>

<body>
</body>

</html>